//
//  Xmg_Button.m
//  07-个人详情页(导航控制器注意点)
//
//  Created by xhkj on 2018/7/2.
//  Copyright © 2018年 小码哥. All rights reserved.
//

#import "Xmg_Button.h"


@interface Xmg_Button()

@end


@implementation Xmg_Button


-(instancetype)initWithFrame:(CGRect)frame{
    
    
    if (self=[super initWithFrame:frame]) { 
        [self setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        self.titleLabel.backgroundColor=[UIColor redColor];
        self.contentMode=UIViewContentModeScaleAspectFill;
        UIViewContentModeScaleAspectFit,
        self.backgroundColor=[UIColor whiteColor];
        self.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
        
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
    }
    
    return self;
}


- (CGRect)contentRectForBounds:(CGRect)bounds{
    
    return self.frame;
    
}
-(CGRect)titleRectForContentRect:(CGRect)contentRect

{
    
    CGFloat titleY = contentRect.size.height *0.8;
    
    CGFloat titleW = CGRectGetWidth(contentRect);
    
    CGFloat titleH = contentRect.size.height - titleY;
    
    return CGRectMake(0, titleY, titleW, titleH);
    
}

-(CGRect)imageRectForContentRect:(CGRect)contentRect

{
    
    //CGFloat imageW = CGRectGetWidth(contentRect);
    
    CGFloat imageH = contentRect.size.height * 0.7;
    CGFloat imageW = imageH;
    
    return CGRectMake((contentRect.size.width-imageW)/2, 0, imageW, imageH);
    
}


@end
